<template>
  <nav class="header-nav">
    <ul class="nav-box">
      <li class="nav-minbox" v-for="(item,index) in headerTitle" :key="index" @click="navIndex = index">
        <router-link :to="item.url" active-class="active" >
          <svg class="icon" aria-hidden="true" style="font-size: 24px">
            <use :xlink:href="item.icon"></use>
          </svg>
          {{item.title}}</router-link>
      </li>
    </ul>
  </nav>
</template>

<script>
export default {
  name: 'HeaderNav',

  data() {
    return {
      headerTitle:[ //导航标题数据
        {title: '首页', url: '/home', icon: '#icon-index1'},
        {title: '聊天大厅', url: '/chat', icon: '#icon-liaotianshi-dating'},
        {title: '精选文章', url: '/article', icon: '#icon-jingpina'},
        {title: '话题社区', url: '/topic', icon: '#icon-shequ1'},
        {title: '关于我们', url: '/about', icon: '#icon-guanyuwomen'}
      ]
    };
  },

};
</script>

<style scoped>
.header-nav{
  position: relative;
  text-align: center;
  font-size: 1rem;
  flex: 3;
}
.header-nav .nav-box{
  display: flex;
  margin: 0 10px;
}
.header-nav .nav-minbox{
  flex: 1;
  height: 80px;
  line-height: 80px;
}
.nav-minbox a{
  display: block;
  width: 100%;
  height: 100%;
}
.active{
  color: blue;
  background-color: #bfa;
}
@media screen and (max-width:800px) {
  .header-nav{
    position: fixed;
    width: 180px;
    height: 100vh;
    background-color: white;
    top: 0;
    left: -100%;
    z-index: 9999;
    transition: all .5s ease;
    border: 1px solid gray;
    border-left: none;
  }
  .nav-box{
    flex-direction: column;
  }
  .header-nav .nav-box{
    margin: 0;
  }
}
</style>